﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Foundation {

    /// <summary>
    /// Die Klasse für die Speicherung der Daten eines Tracks
    /// </summary>
    public class Track {
        public static List<Track> GetTrackListFromFileList(List<string> files){
            List<Track> returnList = new List<Track>(); 
                       
            foreach(string s in files){
                string filename = System.IO.Path.GetFileName(s);
                string path = System.IO.Path.GetDirectoryName(s);
                returnList.Add(new Track(filename, path)); 
            }
            return returnList; 
        }

        /// <summary>
        /// Konstruktor. Wenn die Id noch nicht vergeben wurde, 
        /// wird eine neue vergeben
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="path">Pfad</param>
        public Track(string name, string path) {
            this.Id = this.Id.Equals(Guid.Empty) ? Guid.NewGuid() : this.Id;             
            this.Name = name;
            this.Path = path;            

        }

        public Track(string name, string path, string id) : this(name, path) {
            this.Id = Guid.Parse(id); 
            

        }

        /// <summary>
        /// Namr des Tracks
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Pfad des Tracks
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// ID des Tracks
        /// </summary>
        public Guid Id { get; set; }

        public string FullPath {
            get {
                return string.Format("{0}\\{1}", this.Path, this.Name);
            }
        }

        /// <summary>
        /// Gibt die String Representation des Objektes zurück
        /// </summary>
        /// <returns></returns>
        public override string ToString() {
            return this.Name; 
        }
    }
}
